﻿using System.Configuration;

namespace DIX.Configuration
{
    public class DIXConfiguration : ConfigurationSection
    {
        #region CONSTANT
        
        public const string REPOSITORY = "Repository";
        public const string SECTION = "DIX/DIXConfiguration";
        public const string NAME = "name";

        #endregion

        #region PROPERTY
        
        [ConfigurationProperty(NAME)]
        public string Name
        {
            get
            {
                return (string)this[NAME];
            }
            set
            {
                this[NAME] = value;
            }
        }

        [ConfigurationProperty(REPOSITORY)]
        public DIXRepositoryElement Repository
        {
            get
            {
                return (DIXRepositoryElement)this[REPOSITORY];
            }
            set
            {
                this[REPOSITORY] = value;
            }
        }

        #endregion

        #region METHODS
        
        public static DIXConfiguration GetConfig()
        {
            return (DIXConfiguration)ConfigurationManager.GetSection(SECTION) ?? new DIXConfiguration();
        }

        #endregion
    }
}
